import { request } from './index'

// 级联选择器数据
export function GetListFnc () {
  return request({
    url: 'categories',
    method: 'get'
  })
}

// 得到table数据
export function GetAttrFnc (id: number, data: {sel: string}) { 
  return request({
    url: `/categories/${id}/attributes?sel=${data.sel}`,
    method: 'get'
  })
}

// 添加 动态参数 静态属性
export function AddParamsFnc (cateId: number, data: {attr_name: string, attr_sel: string}) {
  return request({
    url: `/categories/${cateId}/attributes`,
    method: 'post',
    data: data
  })
}

// 打开编辑盒子获取 动态参数 静态属性
export function ShowEditParamsFnc (cateId: number, id: number, data: {attr_sel: string}) { 
  return request({
    url: `/categories/${cateId}/attributes/${id}?attr_sel=${data.attr_sel}`,
    method: 'get'
  })
}

// 修改对应参数信息
export function EditParamsFnc (cateId: number, attrId: number, data: {attr_name: string, attr_sel: string}) { 
  return request({
    url: `/categories/${cateId}/attributes/${attrId}`,
    method: 'put',
    data: data
  })
}

// 删除参数
export function RemoveParamsFnc (cateId: number, attrId: number) { 
  return request({
    url: `/categories/${cateId}/attributes/${attrId}`,
    method: 'delete'
  })
}

// 展开行 tag添加删除
export function TagAddDelFnc (cateId: number, attrId: number, data: {attr_name: string, attr_sel: string, attr_vals: any}) { 
  return request({
    url: `/categories/${cateId}/attributes/${attrId}`,
    method: 'put',
    data: data
  })
}